<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/include/taglibs.jsp" %>
<html>
<head>
    <%@include file="/include/header.html" %>
    <link rel="stylesheet" href="${ctx}/statics/css/blanceDrop.css">
    <link rel="stylesheet" href="${ctx}/statics/css/update.css?v=20200825">
    <link rel="stylesheet" href="${ctx}/statics/css/common.css?v=20200825">
    <%--<link rel="stylesheet" href="${ctx}/libjs/plugins/laydate/laydate.css">--%>
    <%--<script src="${ctx}/libjs/plugins/laydate/laydate.js"></script>--%>
    <script type="text/javascript" src="${ctx}/appjs/tenant/user/tenantSetting.js"></script>
</head>

<script type="text/javascript">
    $('#topLink', window.parent.document).html(function (i, origText) {
        return '<ol class="breadcrumb">' +
            '<li class="breadcrumb-item">' +
            '<a href="">主页</a>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<a>分销商列表</a>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<strong>结算规则详情</strong>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<a href="javascript:window.history.back()"><i class="fa fa-times"></i> 返回</a>' +
            '</li>' +
            '</ol>';
    });

</script>

<body ondragover="allowDrop(event)" ondrop="drop(event)" >
<input type="hidden" id="operatorStationId" value="${acctRule.operatorStationId}">
<input type="hidden" id="tenantOperatorCode" value="${acctRule.tenantOperatorCode}">
<input type="hidden" id="tenantCode" value="${acctRule.tenantCode}">
<input type="hidden" id="acctRuleId" value="${acctRule.acctRuleId}">
<div class="content">
    <div class="container-fluid">
        <div class="row" style="pointer-events: none;">
            <div class="col-md-2 leftBlock">
                <div class="" style="margin:0">
                    <div class="drag_title">结算涉及参数</div>
                    <div class="drag_title mt-10">订单有关</div>
                </div>
                <div id="div1" class="row" style="flex: 0 0 86%; !important;" ondrop="drop(event)" ondragover="allowDrop(event)">
                    <div class="orderVaribaleBlock">
                        <div class=" margin_top">
                            <button id="drag1" class="btn btn-lg copyBtn btn-default variable" draggable="true"
                                    ondragstart="drag(event)" >
                                平台服务费
                            </button>
                            <!-- <label>图表名称</label> -->
                        </div>
                        <div class=" margin_top">
                            <button id="drag2" class="btn btn-lg copyBtn btn-default variable" draggable="true"
                                    ondragstart="drag(event)">
                                平台电费
                            </button>
                            <!-- <label>图表名称</label> -->
                        </div>
                        <div class=" margin_top">
                            <button id="drag3" class="btn btn-lg copyBtn btn-default variable" draggable="true"
                                    ondragstart="drag(event)">
                                平台总金额
                            </button>
                            <!-- <label>图表名称</label> -->
                        </div>
                        <div class=" margin_top">
                            <button id="drag4" class="btn btn-lg copyBtn btn-default variable" draggable="true"
                                    ondragstart="drag(event)">
                                平台优惠金额
                            </button>
                            <!-- <label>图表名称</label> -->
                        </div>
                        <div class=" margin_top">
                            <button id="drag5" class="btn btn-lg copyBtn btn-default variable" draggable="true"
                                    ondragstart="drag(event)">
                                平台实收金额
                            </button>
                            <!-- <label>图表名称</label> -->
                        </div>
                        <div class=" margin_top">
                            <button id="drag6" class="btn btn-lg copyBtn btn-default variable" draggable="true"
                                    ondragstart="drag(event)">
                                平台电量
                            </button>
                            <!-- <label>图表名称</label> -->
                        </div>
                    </div>
                    <div class="drag_title mt-10">开票有关</div>
                    <div class="invoiceVaribaleBlock">
                        <div class=" margin_top">
                            <button id="drag7" class="btn btn-lg copyBtn btn-default variable" draggable="true"
                                    ondragstart="drag(event)">
                                咨询订单金额
                            </button>
                            <!-- <label>图表名称</label> -->
                        </div>
                    </div>
                    <div class="drag_title mt-10">其他</div>
                    <div class="otherBlock">
                        <div class=" margin_top">
                            <button id="drag8" class="btn btn-lg copyBtn btn-default amountInputBlock" style="width:auto;padding: 0;"
                                    draggable="true" ondragstart="drag(event)">
                                <input type="input" class="amountInput"  onkeyup="clearNoNum(this)"
                                       placeholder="自定义数值" >
                            </button>
                        </div>
                    </div>
                    <div class="drag_title mt-10">运算符号</div>
                    <div class="symbolBlock">
                        <div class="margin_top">
                            <button id="drag9" class="btn btn-lg copyBtn btn-default symbol" draggable="true"
                                    ondragstart="drag(event)">
                                +
                            </button>
                            <!-- <label>图表名称</label> -->
                        </div>
                        <div class="margin_top ">
                            <button id="drag10" class="btn btn-lg copyBtn btn-default symbol" draggable="true"
                                    ondragstart="drag(event)">
                                -
                            </button>
                            <!-- <label>图表名称</label> -->
                        </div>
                        <div class="margin_top">
                            <button id="drag11" class="btn btn-lg copyBtn btn-default symbol" draggable="true"
                                    ondragstart="drag(event)">
                                *
                            </button>
                            <!-- <label>图表名称</label> -->
                        </div>
                        <div class="margin_top">
                            <button id="drag12" class="btn btn-lg copyBtn btn-default symbol" draggable="true"
                                    ondragstart="drag(event)">
                                /
                            </button>
                            <!-- <label>图表名称</label> -->
                        </div>
                        <div class=" margin_top">
                            <button id="drag13" class="btn btn-lg copyBtn btn-default symbol" draggable="true"
                                    ondragstart="drag(event)">
                                (
                            </button>
                            <!-- <label>图表名称</label> -->
                        </div>
                        <div class=" margin_top">
                            <button id="drag14" class="btn btn-lg copyBtn btn-default symbol" draggable="true"
                                    ondragstart="drag(event)">
                                )
                            </button>
                            <!-- <label>图表名称</label> -->
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-md-10 rightBlock drag_outer">
                <div style="background: #fff;padding: 0 20px">
                    <div class="row ">
                        <h1>结算规则</h1>
                    </div>
                    <div class="rightBlockOuter">
                        <%--<div class="labelFont">结算规则：</div>--%>
                        <div class="ruleOperateWrap">
                            <span class="emptyLabel">结算电费=</span>
                            <div class="drag_parent">
                                <div id="div2" class="drag_child drag_left drag_child1" ondragover="allowDrop(event)" ondrop="drop(event)">
                                </div>
                            </div>
                        </div>
                        <div class="previewBlock">
                            <div class="emptyLabel" style="opacity: 0">结算电费=</div>
                            <div class="previewInnerBlock">
                                <div class="preview preview1">预览：结算电费=</div>
                                <span class="functionBtn resetBtn1">重新设置</span>
                                <%--<span class="functionBtn selectMouldBtn" type="elec">选取模板</span>--%>
                            </div>
                            <button class="btn input-distance selectMouldBtn" type="elec">选取模板
                            </button>
                            <button class="btn input-distance templatesBtn" type="elec">存入模板
                            </button>
                            <%--<button class="btn btn-success input-distance confirmAddBtn"   id="drag_save1">确认添加</button>--%>
                            <div class="finalRule1 hide"></div>
                        </div>
                        <%--结算服务费----------------------------------------------------------------------------------------------%>
                        <div class="ruleOperateWrap">
                            <span class="emptyLabel">结算服务费=</span>
                            <div class="drag_parent">
                                <div id="div3" class="drag_child drag_left drag_child2" ondragover="allowDrop(event)" ondrop="drop(event)">
                                </div>
                            </div>
                        </div>
                        <div class="previewBlock">
                            <div class="emptyLabel" style="opacity: 0">结算服务费=</div>
                            <div class="previewInnerBlock">
                                <div class="preview preview2">预览：结算服务费=</div>
                                <span class="functionBtn resetBtn2">重新设置</span>
                                <%--<span class="functionBtn selectMouldBtn" type="service">选取模板</span>--%>
                            </div>
                            <button class="btn input-distance selectMouldBtn" type="service">选取模板
                            </button>
                            <button class="btn input-distance templatesBtn" type="service">存入模板
                            </button>
                            <%--<button class="btn btn-success input-distance confirmAddBtn"   id="drag_save2">确认添加</button>--%>
                            <div class="finalRule2 hide"></div>
                        </div>
                        <div class="remarkExplainBlock">
                            <div class="emptyLabel">结算说明：</div>
                            <textarea name="" id="" cols="30" rows="3">${acctRule.remark}</textarea>
                        </div>
                        <div class="new_rule">
                            <div class="settlementSubItem">结算子项:</div>
                            <div class="new_label" id="newLabel">
                                <div class="first_row" id="first_row">
                                    <button class="btn input-distance add_new" type="gkd" onclick="addnew()">+子项
                                    </button>
                                    <button class="btn input-distance reduce_new" type="gkd" onclick="removenew()">-子项
                                    </button>
                                    <button class="btn input-distance selectMouldBtn" type="gkd">选取模板
                                    </button>

                                    <div class="finalRule3 hide"></div>
                                </div>
                                <div class="new_model" id="newModel">
                                    <button class="model_one">+</button>
                                    <input class="model_two" type="text">
                                    <span class="model_three">=</span>
                                    <div id="div4" class="drag_child model_f drag_left drag_child3" ondragover="allowDrop(event)" ondrop="drop(event)">

                                    </div>
                                    <button class="btn input-distance templatesBtn model_six" type="gkd"> 存入模板
                                    </button>
                                    <button class="model_five delBtn">删除</button>
                                </div>

                            </div>
                        </div>
                    </div>
                    <div class="col-md-12 ruleSetBlock">
                        <div class="row ">
                            <h1>结算设置</h1>
                        </div>
                        <div class="row_Block">
                            <div class="emptyLabel">账单日：</div>
                            <select name="" id="settlementMethod" style="width: 0.5rem !important;">
                                <option value="0" <c:if test="${acctRule.settlementMethod eq '0'}">selected</c:if>>月结</option>
                                <option value="1" <c:if test="${acctRule.settlementMethod eq '1'}">selected</c:if>>半月结</option>
                                <option value="2" <c:if test="${acctRule.settlementMethod eq '2'}">selected</c:if>>日结</option>
                            </select>
                            <input type="text" min="1" max="31" class="acctDay" value="${acctRule.acctDay}"
                                   oninput="if(value>28)value=28;if(value<1)value=''"
                                   onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"
                                   onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'0')}else{this.value=this.value.replace(/\D/g,'')}" />
                            <input type="text" min="1" max="31" class="halfMonthDay hide" value="${acctRule.halfMonthDay}"
                                   oninput="if(value>28)value=28;if(value<1)value=''"
                                   onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"
                                   onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'0')}else{this.value=this.value.replace(/\D/g,'')}" /><span class="hao">号</span>
                            <div class="acctTips">（结算统计周期为设置账单日的00:00:00至下一账单日前一天的23:59:59）</div>
                        </div>
                        <div class="row_Block">
                            <div class="emptyLabel">账单生成时间：</div>
                            次日<input type="text" oninput="if(value>23)value=23;if(value<1)value=''" value="${acctRule.runTime}"
                                     onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"
                                     onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'0')}else{this.value=this.value.replace(/\D/g,'')}" id="runTime">时
                        </div>
                        <div class="row_Block">
                            <div class="emptyLabel">规则生效时间：</div>
                            <input type="text" value="<fmt:formatDate value="${acctRule.ruleStartTime}" pattern="yyyy-MM-dd HH:mm:ss" />" id="ruleStartTime"/>至<input type="text" value="<fmt:formatDate value="${acctRule.ruleEndTime}" pattern="yyyy-MM-dd HH:mm:ss" />" id="ruleEndTime">
                            <div class="acctTips blodAcctTips">时间失效，则规则失效</div>
                        </div>
                    </div>
                </div>

                <div class="col-md-12 submitBlock">
                    <%--<button type="button" class="btn btn-success input-distance leftBtn setUpHistoryBtn">设置记录</button>--%>
                    <button type="button" class="btn btn-success input-distance rightBtn formConfirmBtn">确定</button>
                </div>



                <%--<弹窗>--%>
                <div class="acctRuleModal acctRuleNameModal acctModal hide">
                    <p class="closeBtn" onclick="hide(this)">X</p>
                    <div class="tips2">
                        <span>请为该规则命名:</span><input type="text" class="ruleName">
                        <div class="col-md-12 submitBlock">
                            <%--<button type="button" class="btn btn-success input-distance leftBtn returnBtn">返回上一步</button>--%>
                            <button type="button" class="btn btn-success input-distance rightBtn nameConfirmBtn">确定</button>
                        </div>
                    </div>

                </div>

                <%--编辑模板名称--%>
                <div class="editAcctRuleModal acctModal hide">
                    <p class="closeBtn" onclick="hide(this)">X</p>
                    <div class="tips2">
                        <span>请为该规则命名:</span><input type="text" class="ruleName">
                        <div class="col-md-12 submitBlock">
                            <%--<button type="button" class="btn btn-success input-distance leftBtn returnBtn">返回上一步</button>--%>
                            <button type="button" class="btn btn-success input-distance rightBtn editNameConfirmBtn">确定</button>
                        </div>
                    </div>

                </div>
                <%--<弹窗>--%>
                <%--结算电费模板规则库--%>
                <div class="acctRuleLiBrary acctModal hide" style="height: 400px;width: 500px">
                    <div class="elecRuleLiBrary">
                        <p class="title">请选择合适的结算电费规则模板</p>
                        <div class="ibox-body submitBlock">
                            <input type="text" name="ruleName" id="elecRuleName" placeholder="请输入模板名称" class="form-control input-distance" style="margin-left: -10px;margin-top: 10px;">
                            <button type="button" class="btn btn-success " id="selectBtn" onclick="listAcctRuleRepository('0','reload')" style="margin-left: -10px;">查询</button>
                            <%--<button type="button" class="btn btn-success " id="editBtn" style="margin-left: -10px;">编辑</button>--%>
                            <%--<button type="button" class="btn btn-success delRuleListBtn" style="margin-left: -10px;">删除</button>--%>
                        </div>
                        <div class="acctRuleWrap">

                        </div>
                        <div class="elecRuleBtnWrap hide"></div>
                        <div class="col-md-12 submitBlock">
                            <button type="button" class="btn btn-success input-distance leftBtn" onclick="hide(this)">取消</button>
                            <button type="button" class="btn btn-success input-distance leftBtn delRuleListBtn" >删除</button>
                            <button type="button" class="btn btn-success input-distance leftBtn" id="editBtn" >编辑</button>
                            <button type="button" class="btn btn-success input-distance rightBtn libraryConfirmBtn">确定</button>
                        </div>
                    </div>
                    <%--结算电费模板规则库--%>
                    <%--结算服务费模板规则库--%>
                    <div class="serviceRuleLiBrary hide">
                        <p class="title">请选择合适的结算服务费规则模板</p>
                        <div class="ibox-body submitBlock">
                            <input type="text" name="ruleName" id="serviceRuleName" placeholder="请输入模板名称" class="form-control input-distance" style="margin-left: -10px;margin-top: 10px;">
                            <button type="button" class="btn btn-success " id="serviceSelectBtn" onclick="listAcctRuleRepository('1','reload')" style="margin-left: -10px;">查询</button>
                            <%--<button type="button" class="btn btn-success " id="serviceEditBtn" style="margin-left: -10px;">编辑</button>--%>
                            <%--<button type="button" class="btn btn-success delRuleListBtn" style="margin-left: -10px;">删除</button>--%>
                        </div>
                        <div class="acctRuleWrap">

                        </div>
                        <div class="elecRuleBtnWrap hide"></div>
                        <div class="col-md-12 submitBlock">
                            <button type="button" class="btn btn-success input-distance leftBtn" onclick="hide(this)">取消</button>
                            <button type="button" class="btn btn-success input-distance leftBtn delRuleListBtn" >删除</button>
                            <button type="button" class="btn btn-success input-distance leftBtn" id="serviceEditBtn" onclick="listAcctRuleRepository('1','2')">编辑</button>
                            <button type="button" class="btn btn-success input-distance rightBtn libraryConfirmBtn">确定</button>
                        </div>
                    </div>
                    <div class="gkdRuleLiBrary hide">
                        <p class="title">请选择合适的子项规则模板</p>
                        <div class="ibox-body submitBlock">
                            <input type="text" name="ruleName" id="gkdRuleName" placeholder="请输入模板名称" class="form-control input-distance" style="margin-left: -10px;margin-top: 10px;">
                            <button type="button" class="btn btn-success " id="gkdSelectBtn" onclick="listAcctRuleRepository1('2','reload')" style="margin-left: -10px;">查询</button>
                            <%--<button type="button" class="btn btn-success " id="gkdEditBtn" style="margin-left: -10px;">编辑</button>--%>
                            <%--<button type="button" class="btn btn-success delRuleListBtn" style="margin-left: -10px;">删除</button>--%>
                        </div>
                        <div class="acctRuleWrap">

                        </div>
                        <div class="elecRuleBtnWrap hide"></div>
                        <div class="col-md-12 submitBlock">
                            <button type="button" class="btn btn-success input-distance leftBtn" onclick="hide(this)">取消</button>
                            <button type="button" class="btn btn-success input-distance leftBtn delRuleListBtn " >删除</button>
                            <button type="button" class="btn btn-success input-distance leftBtn" id="gkdEditBtn" >编辑</button>
                            <button type="button" class="btn btn-success input-distance rightBtn libraryConfirmBtn">确定</button>
                        </div>
                    </div>
                    <%--结算服务费模板规则库--%>
                </div>

            </div>
        </div>
    </div>
</div>
</body>
</html>
<script src="${ctx}/appjs/acct/acctRule.js"></script>
<script src="${ctx}/appjs/acct/childAcctRule.js"></script>
<script src="${ctx}/libjs/plugins/jquery-ui/jquery-ui.min.js"></script>
<script>
    var eleId = 4
    function addnew(){
        if($(".new_model:last").find(".drag_child3").attr("id")){
            eleId = parseInt($(".new_model:last").find(".drag_child3").attr("id").substring(3))+1;
        }
        $('.new_label').append(` <div class="new_model" id="newModel"><button class="model_one">+</button> <input class="model_two" type="text"> <span class="model_three">=</span> <div id="div\${eleId}" class="drag_child model_f drag_left drag_child3" ondragover="allowDrop(event)" ondrop="drop(event)"></div><button class="btn input-distance templatesBtn model_six" type="gkd\"> 存入模板</button><button class="model_five delBtn">删除</button></div>`)
    };
    function removenew(){
        if($(".new_model:last").find(".drag_child3").attr("id")){
            eleId = parseInt($(".new_model:last").find(".drag_child3").attr("id").substring(3))+1;
        }
        $('.new_label').append(` <div class="new_model" id="newModel"><button class="model_one">-</button> <input class="model_two" type="text"> <span class="model_three">=</span> <div id="div\${eleId}" class="drag_child model_f drag_left drag_child3" ondragover="allowDrop(event)" ondrop="drop(event)"></div><button class="btn input-distance templatesBtn model_six" type="gkd\"> 存入模板</button><button class="model_five delBtn">删除</button></div>`)

    };
    $(".new_rule").on("click",".delBtn",function () {
        $(this).parent(".new_model").remove()
    })
    $(".new_rule").on("click",".delBtn",function () {
        $(this).parent(".new_model").remove()
    })

    $(function(){
        $('#div2').sortable({
            // axis: "x",
            cursor:"move",
            items:".copyBtn",
            start:function(event,ui){
                // alert(4343)
            },
            update: function( event, ui ) {
                console.error(ui);
            }
        });
    });

    var settlementMethod=$("#settlementMethod").val();
    if (settlementMethod=="2"){
        $(".halfMonthDay").addClass("hide").val("");
        $(".acctDay").addClass("hide").val();
        $(".hao").addClass("hide");
    }

    $("#settlementMethod").change(function () {
        if($(this).val()=="0"){
            $(".halfMonthDay").addClass("hide").val("");
            $(".acctDay").removeClass("hide").val();
        }else if($(this).val()=="1"){
            $(".halfMonthDay").removeClass("hide").val("");
            $(".acctDay").removeClass("hide").val();
        }else{
            $(".halfMonthDay").addClass("hide").val("");
            $(".acctDay").addClass("hide").val();
            $(".hao").addClass("hide");
        }
    })

</script>

